package br.com.duosoftware.orcamento.entidades;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author Renato
 *
 */
@Entity
@Table(name = "unidades_gestoras")
public class UnidadeGestora implements Serializable, BaseEntity {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;
    //
    @Column(length = 2, unique = true)
    private String codigo;
    //
    @Column(length = 80)
    private String descricao;
    //
    @Temporal(TemporalType.DATE)
    @Column(name = "data_inc_unid_orc")
    private Date dataIncUnidOrc = new Date();
    //
    @Temporal(TemporalType.DATE)
    @Column(name = "data_inc_unid_ges")
    private Date dataIncUnidGes = new Date();
    //
    @Column(name = "lei_ges", length = 10)
    private String leiGes;
    //
    @OneToOne
    private TipoOrgao tipoOrgao;

    @Override
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getCodigo() {
        return codigo;
    }

    public void setCodigo(String codigo) {
        this.codigo = codigo;
    }

    public String getDescricao() {
        return descricao;
    }

    public void setDescricao(String descricao) {
        this.descricao = descricao;
    }

    public Date getDataIncUnidOrc() {
        return dataIncUnidOrc;
    }

    public void setDataIncUnidOrc(Date dataIncUnidOrc) {
        this.dataIncUnidOrc = dataIncUnidOrc;
    }

    public Date getDataIncUnidGes() {
        return dataIncUnidGes;
    }

    public void setDataIncUnidGes(Date dataIncUnidGes) {
        this.dataIncUnidGes = dataIncUnidGes;
    }

    public String getLeiGes() {
        return leiGes;
    }

    public void setLeiGes(String leiGes) {
        this.leiGes = leiGes;
    }

    public TipoOrgao getTipoOrgao() {
        return tipoOrgao;
    }

    public void setTipoOrgao(TipoOrgao tipoOrgao) {
        this.tipoOrgao = tipoOrgao;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 53 * hash + (this.id != null ? this.id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final UnidadeGestora other = (UnidadeGestora) obj;
        if (this.id != other.id && (this.id == null || !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return codigo + " - " + descricao;
    }

}
